*******CORPORATE GREEN************
******May 2020*********

****VN:Foreign******
set scheme plottig, perm
cap cd "C:\Users\ejm5\Dropbox\CorporateGreen"


/**********************INTERACTION BETWEEN VNESE FOREIGN AND DOMESTIC FIRMS*******************************************************/
#delimit;
use "Data/DDI_trimmed.dta", clear;
append using  "Data/FDI_trimmed.dta";
generate treat_FDI=treatment2*FDI;

tab export FDI;
lab values FDI FDI;
lab define FDI 1 "Foreign Firm" 0 "Domestic Firm";

generate FDI2=FDI;
replace FDI2=2 if FDI==1;
replace FDI2=1 if FDI==0 & export==1;
replace FDI2=3 if FDI==1 & export==1;
lab values FDI2 FDI2;
lab define FDI2 3 "Foreign Exporter" 2 "Foreign Firm" 1 "Domestic Exporter" 0 "Domestic Firm";
replace labor_size2=5 if labor_size2>=5 & labor_size2<10;
replace labor_size2=. if labor_size2>5;
#delimit;
replace equity=5 if equity>=5 & equity<10;
replace equity=. if equity>5;
replace green_spending2=0 if green_spending==0;
replace env_impact= env_impact_cons if env_impact==0|env_impact==.;

tab env_impact;
tab a10;
tab env_impact if a10==1|a10==2;

#delimit;
generate ln_env_risk2=ln(env_risk2+.01);

merge m:1 pci_id using "Data/enterprises.dta";

save "Data/20201226_CorporateGreen.dta", replace;

/*Appendix 2 and Appendix 3*/
foreach var in treatment2 green_spending green_spending2 FDI export age a1 labor_size2 equity env_risk1 ln_env_risk2 env_impact {;
mean `var' [pweight=1/ent_share];
	};


pwcorr treatment2 green_spending green_spending2 FDI export age a1 labor_size2 equity env_risk1 ln_env_risk2 env_impact, star(5);


/*Appendix 4: Balance*/
#delimit;
generate social=1 if treatment2==0;
replace social=0 if treatment2==1;
gen regulatory=1 if treatment2==1;
replace regulatory=0 if treatment2==0;

generate manufacturing=1 if broad_sector==2;
replace manufacturing=0 if broad_sector!=2;

generate LLC=1 if a8==2;
replace LLC=0 if a8!=2;

generate expand=1 if a10<=2;
replace expand=0 if a10>2;

replace expand=1 if a13<=2;
replace expand=0 if a10>2;


#delimit;
reg a1  regulatory social [pweight=1/ent_share] , nocons;
outreg2 using "Outputs\Tables\Appendix4", tdec(3) bdec(3) noaster replace;
reg a1  regulatory  social [pweight=1/ent_share] ;
outreg2 using "Outputs\Tables\Appendix4", tdec(3) bdec(3) noaster pvalue;
foreach x in  green_spending green_spending2 FDI export age a1 labor_size2  env_risk1 ln_env_risk2 manufacturing LLC expand equity ln_profitmargin env_impact {;
reg `x' regulatory  social [pweight=1/ent_share]  , nocons;
outreg2 using "Outputs\Tables\Appendix4", tdec(3) bdec(3) noaster;
reg `x' regulatory [pweight=1/ent_share] ;
outreg2 using "Outputs\Tables\Appendix4", tdec(3) bdec(3) noaster pvalue;
};

outreg2 using "Outputs\Tables\Appendix4", tdec(3) bdec(3) pvalue excel;
#delimit;
describe green_spending green_spending2 FDI export age a1 labor_size2  env_risk1 ln_env_risk2 manufacturing LLC expand equity ln_profitmargin env_impact;


/**Table 2**/
#delimit;
areg green_spending i.treatment2  i.age labor_size2 i.a8  [pweight=1/ent_share] , absorb(broad_sector) cluster(pci_id);
outreg2 using "Outputs/Tables/Table2", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-Baseline) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^) 
addtext("Categorical Age FE", YES, Broad Sector FE, YES, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, NO) replace;

areg green_spending i.treatment2  i.a1 labor_size2 i.a8  [pweight=1/ent_share] , absorb(sector_plus) cluster(pci_id);
outreg2 using "Outputs/Tables/Table2", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-2Dig) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^)  
addtext("Categorical Age FE", YES, Broad Sector FE, NO, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, YES);

areg green_spending2 i.treatment2  i.age labor_size2 i.a8  [pweight=1/ent_share] , absorb(broad_sector) cluster(pci_id);
outreg2 using "Outputs/Tables/Table2", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-Baseline) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^)  
addtext("Categorical Age FE", YES, Broad Sector FE, YES, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, NO);

areg green_spending2 i.treatment2  i.a1 labor_size2 i.a8  [pweight=1/ent_share] , absorb(sector_plus) cluster(pci_id);
outreg2 using "Outputs/Tables/Table2", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-2Dig) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^)  
addtext("Categorical Age FE", YES, Broad Sector FE, NO, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, YES) excel;

/*****************************************************************************************************************************************/
/**Table 3**/
#delimit;
areg green_spending i.treatment2##i.FDI  i.age labor_size2 i.a8  [pweight=1/ent_share] , absorb(broad_sector) cluster(pci_id);
outreg2 using "Outputs/Tables/Table3", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-Baseline) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^) 
addtext("Categorical Age FE", YES, Broad Sector FE, YES, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, NO) replace;

areg green_spending i.treatment2##i.FDI  i.a1 labor_size2 i.a8  [pweight=1/ent_share] , absorb(sector_plus) cluster(pci_id);
outreg2 using "Outputs/Tables/Table3", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-2Dig) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^)  
addtext("Categorical Age FE", YES, Broad Sector FE, NO, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, YES);

areg green_spending2 i.treatment2##i.FDI  i.age labor_size2 i.a8  [pweight=1/ent_share] , absorb(broad_sector) cluster(pci_id);
outreg2 using "Outputs/Tables/Table3", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-Baseline) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^)  
addtext("Categorical Age FE", YES, Broad Sector FE, YES, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, NO);

areg green_spending2 i.treatment2##i.FDI  i.a1 labor_size2 i.a8  [pweight=1/ent_share] , absorb(sector_plus) cluster(pci_id);
outreg2 using "Outputs/Tables/Table3", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-2Dig) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^)  
addtext("Categorical Age FE", YES, Broad Sector FE, NO, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, YES) excel;

/*****************************************************************************************************************/
/**Table 4**/
#delimit;
areg green_spending i.treatment2##i.FDI2  i.age labor_size2 i.a8 , absorb(broad_sector) cluster(pci_id);
outreg2 using "Outputs/Tables/Table4", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-Baseline) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^) 
addtext("Categorical Age FE", YES, Broad Sector FE, YES, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, NO) replace;

areg green_spending i.treatment2##i.FDI2  i.a1 labor_size2 i.a8 , absorb(sector_plus) cluster(pci_id);
outreg2 using "Outputs/Tables/Table4", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-2Dig) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^)  
addtext("Categorical Age FE", YES, Broad Sector FE, NO, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, YES);

#delimit;
areg green_spending2 i.treatment2##i.FDI2  i.age labor_size2 i.a8 , absorb(broad_sector) cluster(pci_id);
outreg2 using "Outputs/Tables/Table4", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-Baseline) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^) 
addtext("Categorical Age FE", YES, Broad Sector FE, YES, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, NO);

areg green_spending2 i.treatment2##i.FDI2  i.a1 labor_size2 i.a8 , absorb(sector_plus) cluster(pci_id);
outreg2 using "Outputs/Tables/Table4", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-2Dig) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^)  
addtext("Categorical Age FE", YES, Broad Sector FE, NO, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, YES) excel;

/****************************************************************************/
/**Table 5**/
#delimit;
areg green_spending i.treatment2##i.env_impact  i.a1 labor_size2 i.a8 [pweight=1/ent_share] , absorb(sector_plus) cluster(pci_id);
outreg2 using "Outputs/Tables/Table5", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-2Dig) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^)  
addtext("Categorical Age FE", YES, Broad Sector FE, NO, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, YES) replace;

areg green_spending i.treatment2##i.env_impact  i.a1 labor_size2 i.a8 [pweight=1/ent_share]   if FDI==0 , absorb(sector_plus) cluster(pci_id);
outreg2 using "Outputs/Tables/Table5", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-2Dig) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^)  
addtext("Categorical Age FE", YES, Broad Sector FE, NO, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, YES);

areg green_spending i.treatment2##i.env_impact  i.a1 labor_size2 i.a8 [pweight=1/ent_share]   if FDI==1 , absorb(sector_plus) cluster(pci_id);
outreg2 using "Outputs/Tables/Table5", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-2Dig) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^)  
addtext("Categorical Age FE", YES, Broad Sector FE, NO, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, YES);

areg green_spending i.treatment2##i.env_impact  i.a1 labor_size2 i.a8  if FDI2==0, absorb(sector_plus) cluster(pci_id);
outreg2 using "Outputs/Tables/Table5", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-2Dig) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^)  
addtext("Categorical Age FE", YES, Broad Sector FE, NO, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, YES);

areg green_spending i.treatment2##i.env_impact  i.a1 labor_size2 i.a8  if FDI2==1, absorb(sector_plus) cluster(pci_id);
outreg2 using "Outputs/Tables/Table5", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-2Dig) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^)  
addtext("Categorical Age FE", YES, Broad Sector FE, NO, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, YES);

areg green_spending i.treatment2##i.env_impact  i.a1 labor_size2 i.a8   if FDI2==2, absorb(sector_plus) cluster(pci_id);
outreg2 using "Outputs/Tables/Table5", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-2Dig) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^)  
addtext("Categorical Age FE", YES, Broad Sector FE, NO, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, YES);

areg green_spending i.treatment2##i.env_impact  i.a1 labor_size2 i.a8  if FDI2==3, absorb(sector_plus) cluster(pci_id);
outreg2 using "Outputs/Tables/Table5", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-2Dig) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^)  
addtext("Categorical Age FE", YES, Broad Sector FE, NO, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, YES) excel;


/*****************************************************************************************************************/
/*Table 6*/
#delimit;
areg green_spending i.treatment2##c.env_risk1 performance labor_size2   i.age i.a8 if FDI==1  [pweight=1/ent_share] , absorb(broad_sector) cluster(pci_id);
outreg2 using "Outputs/Tables/Table6", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-2Dig) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^)  
addtext("Categorical Age FE", YES, Broad Sector FE, NO, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, YES) replace;

areg green_spending i.treatment2##c.env_risk1 performance labor_size2  i.a1 i.a8 if FDI==1  [pweight=1/ent_share] , absorb(sector_plus) cluster(pci_id);
outreg2 using "Outputs/Tables/Table6", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-2Dig) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^)  
addtext("Categorical Age FE", YES, Broad Sector FE, NO, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, YES);

areg green_spending i.treatment2##c.env_risk1 performance labor_size2  i.age i.a8 if FDI==0 [pweight=1/ent_share] , absorb(broad_sector) cluster(pci_id);
outreg2 using "Outputs/Tables/Table6", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-2Dig) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^)  
addtext("Categorical Age FE", YES, Broad Sector FE, NO, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, YES);

areg green_spending i.treatment2##c.env_risk1 performance labor_size2  i.a1 i.a8 if FDI==0 [pweight=1/ent_share] , absorb(sector_plus) cluster(pci_id);
outreg2 using "Outputs/Tables/Table6", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-2Dig) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^)  
addtext("Categorical Age FE", YES, Broad Sector FE, NO, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, YES);

areg green_spending2 i.treatment2##c.env_risk1 performance labor_size2  i.age i.a8 if FDI==1  [pweight=1/ent_share] , absorb(broad_sector) cluster(pci_id);
outreg2 using "Outputs/Tables/Table6", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-2Dig) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^)  
addtext("Categorical Age FE", YES, Broad Sector FE, NO, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, YES);

areg green_spending2 i.treatment2##c.env_risk1 performance labor_size2  i.a1 i.a8 if FDI==1  [pweight=1/ent_share] , absorb(sector_plus) cluster(pci_id);
outreg2 using "Outputs/Tables/Table6", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-2Dig) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^)  
addtext("Categorical Age FE", YES, Broad Sector FE, NO, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, YES);

areg green_spending2 i.treatment2##c.env_risk1 performance labor_size2  i.age i.a8 if FDI==0 [pweight=1/ent_share], absorb(broad_sector) cluster(pci_id);
outreg2 using "Outputs/Tables/Table6", bdec(3) tdec(3) e(rmse N_clust)  
ctitle(Intensive-2Dig) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^)  
addtext("Categorical Age FE", YES, Broad Sector FE, NO, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, YES);

areg green_spending2 i.treatment2##c.env_risk1 performance labor_size2  i.a1 i.a8 if FDI==0 [pweight=1/ent_share], absorb(sector_plus) cluster(pci_id);
outreg2 using "Outputs/Tables/Table6", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-2Dig) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^)  
addtext("Categorical Age FE", YES, Broad Sector FE, NO, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, YES) excel;

/**********************************/
/*Appendix 5a*/
#delimit;
areg green_spending i.treatment2##c.ln_env_risk2 performance labor_size2   i.age i.a8 if FDI==1  [pweight=1/ent_share], absorb(broad_sector) cluster(pci_id);
outreg2 using "Outputs/Tables/Appendix5a", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-2Dig) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^)  
addtext("Categorical Age FE", YES, Broad Sector FE, NO, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, YES) replace;

areg green_spending i.treatment2##c.ln_env_risk2 performance labor_size2  i.a1 i.a8 if FDI==1  [pweight=1/ent_share], absorb(sector_plus) cluster(pci_id);
outreg2 using "Outputs/Tables/Appendix5a", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-2Dig) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^)  
addtext("Categorical Age FE", YES, Broad Sector FE, NO, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, YES);

areg green_spending i.treatment2##c.ln_env_risk2 performance labor_size2  i.age i.a8 if FDI==0 [pweight=1/ent_share], absorb(broad_sector) cluster(pci_id);
outreg2 using "Outputs/Tables/Appendix5a", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-2Dig) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^)  
addtext("Categorical Age FE", YES, Broad Sector FE, NO, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, YES);

areg green_spending i.treatment2##c.ln_env_risk2 performance labor_size2  i.a1 i.a8 if FDI==0 [pweight=1/ent_share], absorb(sector_plus) cluster(pci_id);
outreg2 using "Outputs/Tables/Appendix5a", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-2Dig) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^)  
addtext("Categorical Age FE", YES, Broad Sector FE, NO, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, YES);

areg green_spending2 i.treatment2##c.ln_env_risk2 performance labor_size2  i.age i.a8 if FDI==1  [pweight=1/ent_share], absorb(broad_sector) cluster(pci_id);
outreg2 using "Outputs/Tables/Appendix5a", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-2Dig) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^)  
addtext("Categorical Age FE", YES, Broad Sector FE, NO, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, YES);

areg green_spending2 i.treatment2##c.ln_env_risk2 performance labor_size2  i.a1 i.a8 if FDI==1  [pweight=1/ent_share], absorb(sector_plus) cluster(pci_id);
outreg2 using "Outputs/Tables/Appendix5a", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-2Dig) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^)  
addtext("Categorical Age FE", YES, Broad Sector FE, NO, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, YES);

areg green_spending2 i.treatment2##c.ln_env_risk2 performance labor_size2  i.age i.a8 if FDI==0 [pweight=1/ent_share], absorb(broad_sector) cluster(pci_id);
outreg2 using "Outputs/Tables/Appendix5a", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-2Dig) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^)  
addtext("Categorical Age FE", YES, Broad Sector FE, NO, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, YES);

areg green_spending2 i.treatment2##c.ln_env_risk2 performance labor_size2  i.a1 i.a8 if FDI==0 [pweight=1/ent_share], absorb(sector_plus) cluster(pci_id);
outreg2 using "Outputs/Tables/Appendix5a", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-2Dig) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^)  
addtext("Categorical Age FE", YES, Broad Sector FE, NO, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, YES) excel;


/****************************************************************************************************/
/**Appendix 6a: Subsitututing Equity**/
#delimit;
areg green_spending i.treatment2  i.age equity i.a8  [pweight=1/ent_share], absorb(broad_sector) cluster(pci_id);
outreg2 using "Outputs/Tables/Appendix6a", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-Baseline) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^) 
addtext("Categorical Age FE", YES, Broad Sector FE, YES, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, NO) replace;

areg green_spending i.treatment2  i.a1 equity i.a8  [pweight=1/ent_share], absorb(sector_plus) cluster(pci_id);
outreg2 using "Outputs/Tables/Appendix6a", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-2Dig) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^)  
addtext("Categorical Age FE", YES, Broad Sector FE, NO, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, YES);

areg green_spending2 i.treatment2  i.age equity i.a8  [pweight=1/ent_share], absorb(broad_sector) cluster(pci_id);
outreg2 using "Outputs/Tables/Appendix6a", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-Baseline) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^)  
addtext("Categorical Age FE", YES, Broad Sector FE, YES, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, NO);

areg green_spending2 i.treatment2  i.a1 equity i.a8  [pweight=1/ent_share], absorb(sector_plus) cluster(pci_id);
outreg2 using "Outputs/Tables/Appendix6a", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-2Dig) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^)  
addtext("Categorical Age FE", YES, Broad Sector FE, NO, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, YES) excel;
/*****************************************************************************************************************************************/
/**Appendix 6b" Substituting Equity Size**/
#delimit;
areg green_spending i.treatment2##i.FDI  i.age equity i.a8  [pweight=1/ent_share], absorb(broad_sector) cluster(pci_id);
outreg2 using "Outputs/Tables/Appendix6b", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-Baseline) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^) 
addtext("Categorical Age FE", YES, Broad Sector FE, YES, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, NO) replace;

areg green_spending i.treatment2##i.FDI  i.a1 equity i.a8  [pweight=1/ent_share], absorb(sector_plus) cluster(pci_id);
outreg2 using "Outputs/Tables/Appendix6b", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-2Dig) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^)  
addtext("Categorical Age FE", YES, Broad Sector FE, NO, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, YES);

areg green_spending2 i.treatment2##i.FDI  i.age equity i.a8  [pweight=1/ent_share], absorb(broad_sector) cluster(pci_id);
outreg2 using "Outputs/Tables/Appendix6b", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-Baseline) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^)  
addtext("Categorical Age FE", YES, Broad Sector FE, YES, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, NO);

areg green_spending2 i.treatment2##i.FDI  i.a1 equity i.a8  [pweight=1/ent_share], absorb(sector_plus) cluster(pci_id);
outreg2 using "Outputs/Tables/Appendix6b", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-2Dig) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^)  
addtext("Categorical Age FE", YES, Broad Sector FE, NO, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, YES) excel;

/*********************************************************************************************************************************/
/*Appendix 6C with Equity**/
#delimit;
areg green_spending i.treatment2##i.FDI2  i.age equity i.a8 , absorb(broad_sector) cluster(pci_id);
outreg2 using "Outputs/Tables/Appendix6c", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-Baseline) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^) 
addtext("Categorical Age FE", YES, Broad Sector FE, YES, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, NO) replace;

areg green_spending i.treatment2##i.FDI2  i.a1 equity i.a8, absorb(sector_plus) cluster(pci_id);
outreg2 using "Outputs/Tables/Appendix6c", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-2Dig) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^)  
addtext("Categorical Age FE", YES, Broad Sector FE, NO, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, YES);

#delimit;
areg green_spending2 i.treatment2##i.FDI2  i.age equity i.a8, absorb(broad_sector) cluster(pci_id);
outreg2 using "Outputs/Tables/Appendix6c", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-Baseline) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^) 
addtext("Categorical Age FE", YES, Broad Sector FE, YES, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, NO);

areg green_spending2 i.treatment2##i.FDI2  i.a1 equity i.a8 , absorb(sector_plus) cluster(pci_id);
outreg2 using "Outputs/Tables/Appendix6c", bdec(3) tdec(3) e(rmse N_clust) 
ctitle(Intensive-2Dig) alpha(0.001, 0.01, 0.05, 0.1) symbol(***, **, *, ^)  
addtext("Categorical Age FE", YES, Broad Sector FE, NO, Legal Form FE, YES, License Year FE, NO, 2-Digit ISIC FE, YES) excel;

/**********************************************************************************************************************************************************/
/*Figure 3 (in overleaf as Figure 4.8)*/
#delimit;
xi: interflex green_spending treatment2 env_risk1 i.age i.a8  if FDI==0 , fe(broad_sector) ylabel("Any Investment") dlabel ("GovReg") xlabel("Impact of Climate Change (1-10)") type(binning) cluster(pci_id) title("Domestic Firms");
graph save "Outputs\Figures\size_DDI.gph", replace;

#delimit;
xi: interflex green_spending treatment2 env_risk1 i.age i.a8 if FDI==1 , fe(broad_sector) ylabel("Any Investment") dlabel ("GovReg") xlabel("Impact of Climate Change (1-10)") type(binning) cluster(pci_id) title("Foreign Firms");
graph save "Outputs\Figures\size_FDI.gph", replace;

#delimit;
graph combine "Outputs\Figures\size_DDI.gph" "Outputs\Figures\size_FDI.gph", ycommon imargin(small) rows(1) title("Extensive Margin: Any Green Spending");
graph save "Outputs\Figures\size_any.gph", replace;

#delimit;
xi: interflex green_spending2 treatment2 env_risk1 i.age i.a8 if FDI==0 , fe(broad_sector) ylabel("Amount of Investment") dlabel ("GovReg") xlabel("Impact of Climate Change (1-10)") type(binning) cluster(pci_id) title("Domestic Firms");
graph save "Outputs\Figures\size_DDI2.gph", replace;

#delimit;
xi: interflex green_spending2 treatment2 env_risk1 i.age i.a8 if FDI==1 , fe(broad_sector) ylabel("Amount of Investment") dlabel ("GovReg") xlabel("Impact of Climate Change (1-10)") type(binning) cluster(pci_id) title("Foreign Firms");
graph save "Outputs\Figures\size_FDI2.gph", replace;

#delimit;
graph combine "Outputs\Figures\size_DDI2.gph" "Outputs\Figures\size_FDI2.gph", ycommon imargin(small) rows(1) title("Intensive: Amount of Green Spending");
graph save "Outputs\Figures\size_extensive.gph", replace;


#delimit;
graph combine "Outputs\Figures\size_any.gph" "Outputs\Figures\size_extensive.gph", ycommon imargin(small) rows(2) note("95% CIs; Domestic Firms (n=8,633); Foreign Firms (n=1,561)", position(7) size(vsmall));
graph save "Outputs\Figures\Figure3.gph", replace;
graph export  "Outputs\Figures\Figure3.pdf", as(pdf) replace;

/**********************************************************************************************************************************************************/
/*Appendix5b*/
#delimit;
xi: interflex green_spending treatment2 ln_env_risk2 i.age i.a8 if FDI==0 , fe(broad_sector) ylabel("Any Investment") dlabel ("GovReg") xlabel("Impact of Climate Change (1-10)") type(binning) cluster(pci_id) title("Domestic Firms");
graph save "Outputs\Figures\size_DDI.gph", replace;

#delimit;
xi: interflex green_spending treatment2 ln_env_risk2 i.age i.a8 if FDI==1 , fe(broad_sector) ylabel("Any Investment") dlabel ("GovReg") xlabel("Impact of Climate Change (1-10)") type(binning) cluster(pci_id) title("Foreign Firms");
graph save "Outputs\Figures\size_FDI.gph", replace;

#delimit;
graph combine "Outputs\Figures\size_DDI.gph" "Outputs\Figures\size_FDI.gph", ycommon imargin(small) rows(1) title("Extensive Margin: Any Green Spending");
graph save "Outputs\Figures\size_any.gph", replace;

#delimit;
xi: interflex green_spending2 treatment2 ln_env_risk2 i.age i.a8 if FDI==0 , fe(broad_sector) ylabel("Amount of Investment") dlabel ("GovReg") xlabel("Impact of Climate Change (1-10)") type(binning) cluster(pci_id) title("Domestic Firms");
graph save "Outputs\Figures\size_DDI2.gph", replace;

#delimit;
xi: interflex green_spending2 treatment2 ln_env_risk2 i.age i.a8 if FDI==1 , fe(broad_sector) ylabel("Amount of Investment") dlabel ("GovReg") xlabel("Impact of Climate Change (1-10)") type(binning) cluster(pci_id) title("Foreign Firms");
graph save "Outputs\Figures\size_FDI2.gph", replace;

#delimit;
graph combine "Outputs\Figures\size_DDI2.gph" "Outputs\Figures\size_FDI2.gph", ycommon imargin(small) rows(1) title("Intensive: Amount of Green Spending");
graph save "Outputs\Figures\size_extensive.gph", replace;


#delimit;
graph combine "Outputs\Figures\size_any.gph" "Outputs\Figures\size_extensive.gph", ycommon imargin(small) rows(2) note("95% CIs; Domestic Firms (n=8,633); Foreign Firms (n=1,561)", position(7) size(vsmall));
graph save "Outputs\Figures\Appendix5b.gph", replace;
graph export  "Outputs\FiguresAppendix5b.pdf", as(pdf) replace;



/****************************************************************************************************/
#delimit;
replace green_spending=green_spending*100;
replace gc3b1=gc3b1*100;
replace gc3b2=gc3b2*100;
replace environment_procedure=environment_procedure*100;
replace  environment_inspect=environment_inspect*100;
replace env_impact=env_impact*100;
replace  env_impact2=env_impact2*100;
replace env_impact_cons=env_impact_cons*100;
replace  env_impact_cons2=env_impact_cons2*100;
replace  gc2a=gc2a*100;

/****************************************************************************************************/
/*Figure 1 in Overleaf Figure 4.6X*/
#delimit;
cibar green_spending [pweight=1/ent_share], level(95) barlabel(on)  over1(treatment2)  barcolor(forest_green dkgreen) graphopts(
ytitle("Any Green Spending at all (%)", size(medsmall) margin(small)) legend(rows(2) position(11) ring(0)) title("Extensive Margin: Any Green Spending"));
graph save "Outputs\Figures\FigureGS1_ALL.gph", replace;

#delimit;
cibar green_spending2 [pweight=1/ent_share], level(95) barlabel(on)  over1(treatment2)  barcolor(forest_green dkgreen) graphopts(
ytitle("Share of Green Spending (0-4)", size(medsmall) margin(small)) legend(off)  title("Intensive Margin: Amount of Green Spending"));
graph save "Outputs\Figures\FigureGS2_ALL.gph", replace;

graph combine "Outputs\Figures\FigureGS1_ALL.gph" "Outputs\Figures\FigureGS2_ALL.gph", xcommon imargin(small) rows(2) note("Using Inverse Probability Weights; Range Bars=95% CIs; Domestic Firms (n=8,663) and Foreign Firms (n=1,561)", position(7) size(vsmall));
graph save "Outputs\Figures\Figure1.gph", replace;
graph export  "Outputs\Figures\Figure1.pdf", as(pdf) replace;
/****************************************************************************************************/

/*Figure 2 in Overleaf Figure 4.7*/
#delimit;
cibar green_spending, level(95) barlabel(on)  over1(treatment2) over2(FDI2) barcolor(forest_green dkgreen) graphopts(
ytitle("Any Green Spending at all (%)", size(medsmall) margin(small)) legend(rows(2) position(11) ring(0)) title("Extensive Margin: Any Green Spending"));
graph save "Outputs\Figures\FigureGS1_ALL.gph", replace;

#delimit;
cibar green_spending2, level(95) barlabel(on)  over1(treatment2) over2(FDI2) barcolor(forest_green dkgreen) graphopts(
ytitle("Share of Green Spending (%)", size(medsmall) margin(small)) legend(off)  title("Intensive Margin: Amount of Green Spending"));
graph save "Outputs\Figures\FigureGS2_ALL.gph", replace;

graph combine "Outputs\Figures\FigureGS1_ALL.gph" "Outputs\Figures\FigureGS2_ALL.gph", xcommon imargin(small) rows(2) note("Using Inverse Probability Weights; Range Bars=95% CIs; Domestic Firms (n=6,882); Domestic Exporters (n=1,750); Foreign Firms (n=804); Foreign Exporters (n=757)", position(7) size(vsmall));
graph save "Outputs\Figures\Figure2.gph", replace;
graph export  "Outputs\Figures\Figure2.pdf", as(pdf) replace;
/****************************************************************************************************/

#delimit;
generate inverse=1/ent_share;
svyset id [pweight=inverse], strata(pci_id) vce(linearized) singleunit(missing);

#delimit;
svy: tab green_spending2 treatment, col;
svy: tab green_spending2 treatment if FDI==0,  col;
svy: tab green_spending2 treatment if FDI==1, col;
tab green_spending2 treatment if FDI2==0,  col nofreq;
tab green_spending2 treatment if FDI2==1,  col nofreq;
tab green_spending2 treatment if FDI2==2,  col nofreq;
tab green_spending2 treatment if FDI2==3,  col nofreq;


/*Sunstantive Effects*/
display .32*36278;
display .06*11609;
display .02*79280;
display .113*36278;
display .043*4099.414;
display .05*79280;
display .048*36278;
display .04*1741.344;
display .10*79280;
display 150000000/23000;
display 180000000/23000;
display 1800000/23000;
display .67*36278;
display .07*24306.26;
display .67*439;
display .07*294;